/* 响应式设计系统 */

/* 响应式断点定义 */
:root {
  --breakpoint-xs: 320px;
  --breakpoint-sm: 480px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-xxl: 1536px;
}

/* 基础响应式重置 */
* {
  box-sizing: border-box;
}

html {
  /* 防止iOS Safari缩放 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  /* 防止滚动条抖动 */
  overflow-y: scroll;
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  /* 移除触摸设备上的hover效果 */
  *:hover {
    transform: none !important;
  }
  
  /* 增加触摸目标的最小尺寸 */
  button, 
  .link-item, 
  .search-button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 优化输入框在iOS上的显示 */
  input, select, textarea {
    font-size: 16px; /* 防止iOS缩放 */
  }
}

/* 安全区域适配（iPhone X及更新机型） */
@supports (padding: max(0px)) {
  .safe-area-top {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  
  .safe-area-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  
  .safe-area-left {
    padding-left: max(1rem, env(safe-area-inset-left));
  }
  
  .safe-area-right {
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* 高性能动画优化 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  :root {
    --color-background: #000000;
    --color-text: #ffffff;
  }
}

/* 暗色模式优化 */
@media (prefers-color-scheme: dark) {
  :root {
    --color-scheme: dark;
  }
}

/* 打印样式 */
@media print {
  .theme-toggle,
  .search-tips,
  .remove-btn {
    display: none !important;
  }
  
  .homepage-container {
    background: white !important;
    color: black !important;
  }
  
  .link-item {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
  }
}

/* 响应式工具类 */
.container {
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 768px) {
  .container {
    max-width: 720px;
    padding: 0 2rem;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 960px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1140px;
  }
}

/* 响应式文本工具类 */
.text-responsive {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.heading-responsive {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

/* 响应式间距工具类 */
.spacing-responsive {
  padding: clamp(1rem, 3vw, 2rem);
}

/* 响应式网格系统 */
.grid-responsive {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: clamp(0.5rem, 2vw, 1rem);
}

/* 响应式图片 */
img.responsive {
  max-width: 100%;
  height: auto;
}

/* 防止文本溢出 */
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 移动端优化类 */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
}

/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
  .landscape-compact {
    padding: 0.5rem;
  }
  
  .landscape-hidden {
    display: none;
  }
}

/* 性能优化：延迟加载图片的占位符 */
.lazy-load {
  background: #f0f0f0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* 焦点可见性优化 */
.focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* 减少动画（用户偏好） */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
